<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>闪聊</title>
    <script src="js/mui.min.js"></script>
    <link href="css/mui.min.css" rel="stylesheet"/>
	<link rel="stylesheet" type="text/css" href="css/header.css"/>
	<link rel="stylesheet" type="text/css" href="ext-img/iconfont.css"/>
    <script type="text/javascript" charset="utf-8">
      	mui.init();
		mui.plusReady(function() {
			plus.navigator.setStatusBarStyle('light');
			plus.navigator.setStatusBarBackground('#c9394a');
		});
    </script>
</head>
<body>
	<header class="mui-bar mui-bar-nav title">
		<h1 class="mui-title title-color">
			<b>闪聊</b>
		</h1>
	</header>
	
	
	<nav class="mui-bar mui-bar-tab">
		<a class="mui-tab-item mui-active" data-index="0">
			<span class="mui-icon iconfont icon-chat"></span>
			<span class="mui-tab-label">聊天</span>
		</a>
		<a class="mui-tab-item" data-index="1">
			<span class="mui-icon iconfont icon-contacts"></span>
			<span class="mui-tab-label">通讯录</span>
		</a>
		<a class="mui-tab-item" data-index="2">
			<span class="mui-icon iconfont icon-pengyouquan"></span>
			<span class="mui-tab-label">发现</span>
		</a>
		<a class="mui-tab-item" data-index="3">
			<span class="mui-icon iconfont icon-wode1"></span>
			<span class="mui-tab-label">我的</span>
		</a>
	</nav>
	
	<script type="text/javascript">
		var tabArray = [
			{
				pageId: 'bottom-chat.html',
				pageUrl: 'bottom-chat.html'
			},
			{
				pageId: 'bottom-contact.html',
				pageUrl: 'bottom-contact.html'
			},
			{
				pageId: 'bottom-discovery.html',
				pageUrl: 'bottom-discovery.html'
			},
			{
				pageId: 'bottom-me.html',
				pageUrl: 'bottom-me.html'
			}
		];
		
		var tabStyle = {
			top: '44px',
			bottom: '50px'
		}
		
		mui.plusReady(function() {
			var indexWebview = plus.webview.currentWebview();
			
			for (var i = 0; i < tabArray.length; i++) {
				var item = tabArray[i];
				var page = plus.webview.create(item.pageUrl, item.pageId, tabStyle);
				page.hide();
				indexWebview.append(page);
			}
			
			plus.webview.show(tabArray[0].pageId);
			
			mui('.mui-bar-tab').on('tap', 'a', function() {
				var tabIndex = this.getAttribute('data-index');
				plus.webview.show(tabArray[tabIndex].pageId, 'fade-in', 300);
				
				for (var i = 0; i < tabArray.length; i++) {
					if (i !== tabIndex) {
						plus.webview.hide(tabArray[i].pageId, 'fade-out', 300);
					}
				}
			})
		});
	</script>
</body>
</html>